﻿// Copyright (c) 2009 Kjetil Eraker Samuelsen
// This source is subject to the Microsoft Public License.
// See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
// All other rights reserved.

using System;
using System.Drawing;
using System.Windows.Forms;

namespace Ksamuelsen.Office.Outlook {
    public class OutlookPropertyPageDivider : Label {
        private static Pen[] _lines = { new Pen(SystemColors.ControlDark), new Pen(SystemColors.ControlLightLight) };

        public OutlookPropertyPageDivider() {
            AutoSize = false;
        }

        protected override void OnResize(EventArgs e) {
            base.OnResize(e);
            Invalidate();
        }

        protected override void OnPaint(PaintEventArgs e) {
            base.OnPaint(e);
            SizeF textSize = e.Graphics.MeasureString(Text, Font);
            Padding padding = Padding;
            float x = textSize.Width + ((float)Padding.Left) + 5f;
            float y = (textSize.Height / 2f) + ((float)padding.Top);

            int width = Width - (int)x;
            for (int i = 0; i < _lines.Length; i++) {
                e.Graphics.DrawLine(_lines[i], x, y + i, x + width, y + i);
            }
        }




    }
}
